<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,initial-scale=1.0,width=device-width"/>
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>大奔农庄</title>
    <link rel="stylesheet" type="text/css" href="../../css/api.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/aui.css"/>
    <link rel="stylesheet" type="text/css" href="../../css/style.css"/>    
    <link rel="stylesheet" href="../../css/swiper.min.css">
    <link rel="stylesheet" href="../../font/iconfont.css">
</head>
<body>
<header class="aui-bar aui-bar-nav top-nav" id="title">
	<a class="aui-pull-left aui-btn"></a> 
	<div class="aui-title" id="db_title">大奔农庄</div>
</header>
<div id="db_zhanwei"></div>

<div id="shangcheng_box">
	<!--滚动-->
	<div class="swiper-container">
	    <div class="swiper-wrapper" id="shangchengs_lider">
	    <!-- 
	        <div class="swiper-slide"><img src="../../image/banner2.jpg" width="100%" ></div>
	        <div class="swiper-slide"><img src="../../image/banner2.jpg" width="100%" ></div>
	     -->
	    </div>
	</div>
	<!--滚动结束-->
	<section class="aui-grid in-boxx aui-border-b yinying">
		<div class="aui-row aui-text-center" id="shangcheng_cateheng" style="padding: 0.5rem 0rem 0.2rem 0rem;">			
         <!-- 
	    <div class="aui-col-xs-3 in-tubiao" onclick="openFenlei()">
		    <div class="icon-t"><img src="../../image/sc-1.png"></div>
		    <p style="line-height: 1.2rem; color:#333">全部</p>
		</div>
		<div class="aui-col-xs-3 in-tubiao" onclick="openFenlei()">
			<div class="icon-t"><img src="../../image/sc-2.png"></div>
			<p style="line-height: 1.2rem; color:#333">五谷杂粮</p>
		</div>
		<div class="aui-col-xs-3 in-tubiao" onclick="openFenlei()">
			<div class="icon-t"><img src="../../image/sc-3.png"></div>
			<p style="line-height: 1.2rem; color:#333">一个水果</p>
		</div>
		<div class="aui-col-xs-3 in-tubiao" onclick="openFenlei()">
			<div class="icon-t"><img src="../../image/sc-4.png"></div>
			<p style="line-height: 1.2rem; color:#333">大奔农庄</p>
		</div>
		<div class="aui-col-xs-3 in-tubiao" onclick="openFenlei()">
		    <div class="icon-t"><img src="../../image/sc-1.png"></div>
	        <p style="line-height: 1.2rem; color:#333">全部</p>
		</div>
		<div class="aui-col-xs-3 in-tubiao" onclick="openFenlei()">
			<div class="icon-t"><img src="../../image/sc-2.png"></div>
			<p style="line-height: 1.2rem; color:#333">五谷杂粮</p>
		</div>
		 -->
		</div>
	</section> 
	<!--新品推荐-->
	<div class="qianggou aui-margin-b-15 aui-margin-t-15">
		<div class="miaosha">
			<div class="aui-pull-left">
				<span class="aui-pull-left">新品推荐</span>
			</div>

			<div class="aui-clearfix"></div>
		</div>
		<div class="tuijian-box" id="xinpin_tuijian">
		    <!--
			<div class="tuijian-div">
				<img src="../../image/li1.jpg" class="aui-pull-left" width="200px">
				<div class="aui-pull-left tuijian-zi-div">
					<h4>丹麦森宝1段800g</h4>
					<h5 class="aui-pull-left">￥290.00</h5>
					<div class="aui-clearfix tuijian-gm">立即购买</div>
				</div>
				<div class="aui-clearfix"></div>
			</div>
			<div class="tuijian-div">
				<img src="../../image/li1.jpg" class="aui-pull-left" width="200px">
				<div class="aui-pull-left tuijian-zi-div">
					<h4>丹麦森宝1段800g</h4>
					<h5 class="aui-pull-left">￥290.00</h5>
					<div class="aui-clearfix tuijian-gm">立即购买</div>
				</div>
				<div class="aui-clearfix"></div>
			</div>
			-->
		</div>
	</div>
	

	<div id="shangcheng_categoods">
	<!--
		<div class="qianggou aui-margin-b-15">
			<div class="miaosha" style="border-bottom: 1px #ddd solid;">
				<div class="aui-pull-left">
					<span class="aui-pull-left">人气热销</span>
				</div>
				<img src="../../image/gengduo.png" class="shouye-gengduo">
				<span class="aui-pull-right">
					<a href="#" class="hui">更多</a>
				</span>
				<div class="aui-clearfix"></div>
			</div>
			<div class="xh-cp-ms" style="padding:0px;">
				<div class="auii-col-6 ">
					<div class="photo"><img src="../../image/li1.jpg"></div>
					<h4>丹麦森宝1段800g</h4>
					<h5 class="aui-pull-left">￥290.00</h5>				
					<span>已售：99</span><br>
					<div class="jigm-box">
						<span class="aui-pull-left lj-gm">立即购买</span>
					</div>
				</div>
				<div class="auii-col-6">
					<div class="photo"><img src="../../image/gengduo.png"></div>
					<h4>丹麦森宝1段800g</h4>
					<h5 class="aui-pull-left">￥290.00</h5>					
					<span>已售：99</span><br>
					<div class="jigm-box">
						<span class="aui-pull-left lj-gm">立即购买</span>
					</div>
				</div>
				<div class="auii-col-6 ">
					<img src="../../image/li1.jpg">
					<h4>丹麦森宝1段800g</h4>
					<h5 class="aui-pull-left">￥290.00</h5>				
					<span>已售：99</span><br>
					<div class="jigm-box">
						<span class="aui-pull-left lj-gm">立即购买</span>
					</div>
				</div>
				<div class="auii-col-6">
					<img src="../../image/li1.jpg">
					<h4>丹麦森宝1段800g</h4>
					<h5 class="aui-pull-left">￥290.00</h5>					
					<span>已售：99</span><br>
					<div class="jigm-box">
						<span class="aui-pull-left lj-gm">立即购买</span>
					</div>
				</div>
			</div>
			<div class="aui-clearfix"></div>
		</div>
	 -->
	</div>
</div>	
</body>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/common.js"></script>
<script type="text/javascript" src="../../script/swiper.min.js"></script>
<link rel="stylesheet" type="text/css" href="../../css/aui-pull-refresh.css" />
<script type="text/javascript" src="../../script/aui-pull-refresh.js"></script>
<script>
//变量声明
var db_key = 'user',db_user;
var useParam={}; useParam.rtk = RSapi.myrtk;
//下拉刷新
var pullRefresh = new auiPullToRefresh({
    container: document.querySelector('#shangcheng_box'), //下拉容器
    triggerDistance: 50 //下拉高度
},function(ret){
    if(ret.status=="success"){
        setTimeout( function() {
		 	//加载头部轮播图
		    var sliderbigarr = {rtk: RSapi.myrtk, cate:4};
		    loaddata('shangchengslider',sliderbigarr,RSapi.base+RSapi.shangchengSlider,'shangchengs_lider','1');
		    //加载商品分类横向展示
		    loaddata('shangchengcateheng',useParam,RSapi.base+RSapi.shangchengCateheng,'shangcheng_cateheng','0');
		    //加载商品分类横向展示
			loaddata('xinpintuijian',useParam,RSapi.base+RSapi.shangchengXinpin,'xinpin_tuijian','0');
		    //加载商品分类楼层及商品
		    loaddata('shangchengcategoods',useParam,RSapi.base+RSapi.shangchengCategoods,'shangcheng_categoods','0');
		    //刷新成功后调用此方法隐藏
			pullRefresh.cancelLoading(); 
        },900)
    }
})
//页面初始化
apiready = function() {
	//获取用户信息 
    getuser();
	//监听登录
    api.addEventListener({
        name: 'login_self'
    }, function(ret, err) {
        getuser();
    });
    //监听注销事件
    api.addEventListener({
        name: 'mylogout'
    }, function(ret, err) {
        //更新会员的登录状态
        db_user = $api.getStorage(db_key);
    })
    //加载头部轮播图
    var sliderbigarr = {rtk: RSapi.myrtk, cate:4};
    loaddata('shangchengslider',sliderbigarr,RSapi.base+RSapi.shangchengSlider,'shangchengs_lider','1');
    //加载商品分类横向展示
    loaddata('shangchengcateheng',useParam,RSapi.base+RSapi.shangchengCateheng,'shangcheng_cateheng','0');
    //加载商品分类横向展示
	loaddata('xinpintuijian',useParam,RSapi.base+RSapi.shangchengXinpin,'xinpin_tuijian','0');
    //加载商品分类楼层及商品
    loaddata('shangchengcategoods',useParam,RSapi.base+RSapi.shangchengCategoods,'shangcheng_categoods','0');
}
//获取用户储存在本地的数据
function getuser() {
    db_user = $api.getStorage(db_key);
    try {
        if (db_user.islogin && db_user.mytoken) {
           
        }else {
            domreset();
        }
    }catch(e) {
        domreset();
    }
}
//退出登录或判断用户未登录时，界面显示数据重置
function domreset() {
    db_user = {islogin: false};
    $api.setStorage(db_key,db_user);
}
//加载内容方法
//加载轮播图;flag->轮播图显示位置；1-头部，2-左侧，3-右侧
function loaddata(status,param,url,domid,flag) {
	api.ajax({
		url: url,
		method: 'post',
		cache: false,
		timeout: 30,
		dataType: 'json',
		data: { values: param },
	}, function(ret, err){
		if(err){
//			api.toast({msg: JSON.stringify(err)});
			api.alert({msg: err.msg});
		}else {
			if (ret.status>0) {
				//成功了
				$api.html($api.byId(domid), ' ');
				$api.append($api.byId(domid),ret.info);
				if(flag == 1){
					sliderBig();//大轮播图
				}
				api.parseTapmode();
				eval('status_'+status+'=true;');
			}else {
				//失败了
				api.toast({msg: ret.info});
			}
		}
	});
}
//大轮播图
function sliderBig(){
	var swiper = new Swiper('.swiper-container', {
	    pagination: '.swiper-pagination',
	    nextButton: '.swiper-button-next',
	    prevButton: '.swiper-button-prev',
	    paginationClickable: true,
	    spaceBetween: 30,
	    centeredSlides: true,
	    autoplay: 2500,
	    autoplayDisableOnInteraction: false
	});
}
//打开分类
function openFenlei(cate){
    api.openWin({
        name: 'win_fenlei',
        url: '../win/fenlei_win.html',
        pageParam: {cate: cate}
    });
}
//打开产品
function openGoodsinfo(id,title){
    api.openWin({
        name: 'win_goodsinfo',
        url: '../win/goodsinfo_win.html',
        pageParam: {gid: id,pagetitle:title}
    });
}  
</script>
</html>